/*
 * Copyright 2018-present KunMinX
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *    http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.nsgf.library.ui.adapter;

import android.content.Context;

import androidx.recyclerview.widget.RecyclerView;

import com.kunminx.binding_recyclerview.adapter.SimpleDataBindingAdapter;
import com.nsgf.library.R;
import com.nsgf.library.data.bean.WeatherBean;
import com.nsgf.library.databinding.ItemNsgfWeatherBinding;

/**
 * Create by GC at 24/10/19
 */
public class WeatherListAdapter extends SimpleDataBindingAdapter<WeatherBean.DataBean, ItemNsgfWeatherBinding> {

    public WeatherListAdapter(Context context) {
        super(context, R.layout.item_nsgf_weather, DiffUtils.getInstance().getWeatherCallbacklItemCallback());

    }

    @Override
    protected void onBindItem(ItemNsgfWeatherBinding binding, WeatherBean.DataBean item, RecyclerView.ViewHolder holder) {
        binding.setVm(item);

        switch (item.getItemValue()) {
            default:
            case "weather.type.1"://晴
                binding.ivItemNsgfWeather.setImageResource(R.drawable.ic_manager_work_order_qing);
                break;
            case "weather.type.2"://阴
                binding.ivItemNsgfWeather.setImageResource(R.drawable.ic_manager_work_order_yin);
                break;
            case "weather.type.3"://雨
                binding.ivItemNsgfWeather.setImageResource(R.drawable.ic_manager_work_order_yu);
                break;
            case "weather.type.4"://雪
                binding.ivItemNsgfWeather.setImageResource(R.drawable.ic_manager_work_order_xue);
                break;
        }


        if (item.isSelectWeather()) {
//            binding.llItem.setBackgroundResource(R.drawable.bg_manager_work_order_weather_true);
            binding.ivItemNsgfWeatherCheckbox.setImageResource(R.drawable.ic_chebox_true);
//            binding.tvItemWeather.setTextColor(mContext.getResources().getColor(R.color.white));
        } else {
//            binding.llItem.setBackgroundResource(R.drawable.bg_manager_work_order_weather_false);
            binding.ivItemNsgfWeatherCheckbox.setImageResource(R.drawable.ic_chebox_false);
//            binding.tvItemWeather.setTextColor(mContext.getResources().getColor(R.color.color_1D2129));
        }


    }
}
